package com.yurun.service.impl;

import com.yurun.entity.LoginLog;
import com.yurun.exception.PersistenceException;
import com.yurun.mapper.LoginLogMapper;
import com.yurun.service.LoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoginLogServiceImpl implements LoginLogService {
    @Autowired
    LoginLogMapper loginLogMapper;

    @Override
    public void addLoginLog(LoginLog loginLog){
        if(loginLogMapper.addLoginLog(loginLog)!=1){
            throw new PersistenceException("添加登录日志失败");
        }
    }

    @Override
    public void deleteLoginLogById(Long id){
        if(loginLogMapper.deleteLoginLogById(id)!=1){
            throw new PersistenceException("删除任务日志失败");
        }
    }

    @Override
    public List<LoginLog> getLoginLogListByDate(String startDate, String endDate){
        return loginLogMapper.getLoginLogListByDate(startDate, endDate);
    }
}
